//
//  FunnyTableViewCell.m
//  USB_Reader
//
//  Created by xiaozao on 15/3/23.
//  Copyright (c) 2015年 Tony_Wang. All rights reserved.
//

#import "FunnyTableViewCell.h"

@implementation FunnyTableViewCell

- (void)dealloc
{
    [_content release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.content = [[UILabel alloc] init];
        self.content.backgroundColor = [[UIColor alloc] initWithRed:0.97254902 green:0.97254902 blue:0.97254902 alpha:1];
        self.content.numberOfLines = 0;
        self.content.layer.cornerRadius = 20;

        
        
//        [_content.backgroundColor release];
        [_content release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.layer.cornerRadius = 20;
    self.content.backgroundColor = [UIColor whiteColor];
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGRect rect = [self.content.text boundingRectWithSize:CGSizeMake(self.contentView.frame.size.width , self.contentView.frame.size.height) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.content.frame = CGRectMake(0, 0, self.contentView.frame.size.width, rect.size.height);
    self.content.text = self.data.content;
    [self.contentView addSubview:_content];
    

    NSString *laughLabel = [self.data.votes objectForKey:@"up"];
    NSString *cryLabel = [self.data.votes objectForKey:@"down"];
//    NSLog(@"%@, %@", laughLabel, cryLabel);
    self.laughLabel.text = [NSString stringWithFormat:@"%@",laughLabel];
    self.cryLable.text = [NSString stringWithFormat:@"%@",cryLabel];
    self.laughLabel.frame = CGRectMake(0, 100, 50, 20);

    [self.contentView addSubview:self.laughLabel];
//    self.share.frame = CGRectMake(self.frame.size.width - 60, rect.size.height, 40, 20);
//    self.laugh.frame = CGRectMake(10, rect.size.height, 20, 20);
//    self.cry.frame = CGRectMake(80, rect.size.height, 20, 20);
//    self.laughLabel.frame = CGRectMake(30, rect.size.height, 50, 20);
//    self.cryLable.frame = CGRectMake(100, rect.size.height, 50, 20);
//    self.cry.imageView.image = [UIImage imageNamed: @"cry.png"];
//    self.laugh.imageView.image = [UIImage imageNamed:@"laugh.png"];
//    self.share.imageView.image = [UIImage imageNamed:@"share.png"];
//    [self.contentView addSubview:self.content];
//    [self.contentView addSubview:self.cry];
//    [self.contentView addSubview:self.laugh];
//    [self.contentView addSubview:self.share];
//    [_laugh addTarget:self.laugh action:@selector(buttonActionLaugh:) forControlEvents:UIControlEventTouchUpOutside];
//    [_cry addTarget:self.cry action:@selector(buttonActionCry:) forControlEvents:UIControlEventTouchUpOutside];
//    [_share addTarget:self.share action:@selector(buttonActionShare:) forControlEvents:UIControlEventTouchUpOutside];

    
    
}

- (void)buttonActionLaugh:(UIButton *)button
{
    // 点击笑脸后
}

- (void)buttonActionCry:(UIButton *)button
{
    // 点击哭脸后
}

- (void)buttonActionShare:(UIButton *)button
{
    // 点击分享按钮
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
